Skip to contentSkip to conversation

Change in openvpn[master]: init: Fix datav2_enabled check in options import

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages Oct 14, 2025 – Oct 16, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1760441637000.Ia713a2ecfcad7032863867630a0c306ff9f90385@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1273?usp=email

to review the following change.

Change subject: init: Fix datav2_enabled check in options import
......................................................................

init: Fix datav2_enabled check in options import

peer_id is unsigned, so the previous check was partly useless. Instead check use_peer_id.

Change-Id Ia713a2ecfcad7032863867630a0c306ff9f90385

---
M src/openvpn/init.c

1 file changed, 2 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/73/1273/1

src/openvpn/init.c +2 -2
index aaa0573..aa2611d 100644
@@ -2728,8 +2728,8 @@
 
     /* Ensure that for epoch data format is only enabled if also data v2
      * is enabled */
-    bool epoch_data = (c->options.imported_protocol_flags & CO_EPOCH_DATA_KEY_FORMAT);
-    bool datav2_enabled = (c->options.peer_id >= 0 && c->options.peer_id < MAX_PEER_ID);
+    bool epoch_data = c->options.imported_protocol_flags & CO_EPOCH_DATA_KEY_FORMAT;
+    bool datav2_enabled = c->options.use_peer_id && c->options.peer_id < MAX_PEER_ID;
 
     if (epoch_data && !datav2_enabled)
     {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1273?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia713a2ecfcad7032863867630a0c306ff9f90385
Gerrit-Change-Number: 1273
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1273?usp=email )

Change subject: init: Fix datav2_enabled check in options import
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1273?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia713a2ecfcad7032863867630a0c306ff9f90385
Gerrit-Change-Number: 1273
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 14 Oct 2025 11:51:49 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 init: Fix datav2_enabled check in options import

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

peer_id is unsigned, so the previous check was partly useless. Instead check use_peer_id.

Change-Id Ia713a2ecfcad7032863867630a0c306ff9f90385

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1273
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1273
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>

src/openvpn/init.c +2 -2
index aaa0573..aa2611d 100644
@@ -2728,8 +2728,8 @@
 
     /* Ensure that for epoch data format is only enabled if also data v2
      * is enabled */
-    bool epoch_data = (c->options.imported_protocol_flags & CO_EPOCH_DATA_KEY_FORMAT);
-    bool datav2_enabled = (c->options.peer_id >= 0 && c->options.peer_id < MAX_PEER_ID);
+    bool epoch_data = c->options.imported_protocol_flags & CO_EPOCH_DATA_KEY_FORMAT;
+    bool datav2_enabled = c->options.use_peer_id && c->options.peer_id < MAX_PEER_ID;
 
     if (epoch_data && !datav2_enabled)
     {
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: init: Fix datav2_enabled check in options import

This is one of the "integer" patches that uncovered an actual logic error - checking the wrong variable for the trigger "can I do epoch data?".

This did not hurt so far (because the other checks ensure the right outcome) but I think it de-fuses the "data_v2 must be enabled!" sanity check that would lead to not detecting a non-compliant client. So it's good we found this in time :-)

Not tested beyond "looks reasonable, the BBs say it compiles fine" (the netbsd test fails are due to stuck t_client process from a previous test run abort).

Your patch has been applied to the master branch.

commit c124e50317e530394d9011ddde5653ccfdd94482

Author: Frank Lichtenheld
Date:   Thu Oct 16 12:33:03 2025 +0200
     init: Fix datav2_enabled check in options import

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1273
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg33365.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1273?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by plaisthos

Change subject: init: Fix datav2_enabled check in options import
......................................................................

init: Fix datav2_enabled check in options import

peer_id is unsigned, so the previous check was partly useless. Instead check use_peer_id.

Change-Id Ia713a2ecfcad7032863867630a0c306ff9f90385

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1273
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33365.html

---
M src/openvpn/init.c

1 file changed, 2 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/73/1273/2

src/openvpn/init.c +2 -2
index aaa0573..aa2611d 100644
@@ -2728,8 +2728,8 @@
 
     /* Ensure that for epoch data format is only enabled if also data v2
      * is enabled */
-    bool epoch_data = (c->options.imported_protocol_flags & CO_EPOCH_DATA_KEY_FORMAT);
-    bool datav2_enabled = (c->options.peer_id >= 0 && c->options.peer_id < MAX_PEER_ID);
+    bool epoch_data = c->options.imported_protocol_flags & CO_EPOCH_DATA_KEY_FORMAT;
+    bool datav2_enabled = c->options.use_peer_id && c->options.peer_id < MAX_PEER_ID;
 
     if (epoch_data && !datav2_enabled)
     {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1273?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia713a2ecfcad7032863867630a0c306ff9f90385
Gerrit-Change-Number: 1273
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1273?usp=email )

Change subject: init: Fix datav2_enabled check in options import
......................................................................

init: Fix datav2_enabled check in options import

peer_id is unsigned, so the previous check was partly useless. Instead check use_peer_id.

Change-Id Ia713a2ecfcad7032863867630a0c306ff9f90385

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1273
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33365.html

---
M src/openvpn/init.c

1 file changed, 2 insertions(+), 2 deletions(-)
src/openvpn/init.c +2 -2
index aaa0573..aa2611d 100644
@@ -2728,8 +2728,8 @@
 
     /* Ensure that for epoch data format is only enabled if also data v2
      * is enabled */
-    bool epoch_data = (c->options.imported_protocol_flags & CO_EPOCH_DATA_KEY_FORMAT);
-    bool datav2_enabled = (c->options.peer_id >= 0 && c->options.peer_id < MAX_PEER_ID);
+    bool epoch_data = c->options.imported_protocol_flags & CO_EPOCH_DATA_KEY_FORMAT;
+    bool datav2_enabled = c->options.use_peer_id && c->options.peer_id < MAX_PEER_ID;
 
     if (epoch_data && !datav2_enabled)
     {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1273?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia713a2ecfcad7032863867630a0c306ff9f90385
Gerrit-Change-Number: 1273
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>